<!--
 * @FilePath: Index.vue
 * @Author: jack
 * @Date: 2025-03-18 15:19:37
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-03-18 15:58:06
 * Copyright: 2025 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 
-->
<template>
    <div class="user-info-box">
        <SearchComp @clear="clearHandle" @Search="Search">
            <RowItem label="关键字" :count="1">
                <el-input clearable placeholder="请输入关键字搜索" v-model="personQuery.search" prefix-icon="Search"
                    style="width: 100%">
                </el-input>
            </RowItem>
        </SearchComp>
        <Table :data="tableData" :config="tableConfig" :showLoading="loading" :total="total" @sizeChange="sizeChange"
            @CurrentChange="CurrentChange">
        </Table>
    </div>
</template>
<script setup lang="ts">
import $util from '../../util/util'
import { ref, onMounted, reactive } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
// 引入专属的request配置
import { getReviewList } from '../Api/Staty'
import { PiniaStore } from '../../store'
const delModuleShow = ref(false)
const store = PiniaStore()
const loading = ref(false)
const personQuery = reactive<any>({
    search: '',
    page: 1,
    page_size: store.pageQuery.page_size,
})
const Search = $util.debounce((val: string | number) => {
    personQuery.page = 1
    getList()
}, 500)
// 点击清空条件触发
const clearHandle = () => {
    personQuery.search = ''
    personQuery.page = 1
    getList()
}
// 表格数据
const total = ref(100)
const tableData = ref<any>([])
const tableConfig = ref([
    { name: 'index', label: '序号', width: '60', type: 'index', checked: true },
    { name: 'article_title', label: '文章标题', type: 'change', width: '', checked: true },
    { name: 'attach_name', label: '附件名称', type: 'change', width: '', checked: true },
    { name: 'subject_name', label: '学科', type: 'change', width: '160', checked: true },
    { name: 'avg_score', label: '平均分', type: 'change', width: '140', checked: true },
    { name: 'attach_counts', label: '下载次数', type: 'change', width: '140', checked: true },
    { name: 'user_name', label: '上传人', type: 'change', width: '140', checked: true },
    { name: 'create_date', label: '附件创建时间', type: 'change', width: '180', checked: true },
])
const getList = async () => {
    loading.value = true
    const res: any = await getReviewList(personQuery)
    tableData.value = res.data.list
    total.value = res.data.total
    loading.value = false
}
// 点击翻页器的长度
const sizeChange = () => {
    personQuery.page_size = store.pageQuery.page_size
    getList()
}
// 点击翻页器的页码
const CurrentChange = () => {
    personQuery.page = store.pageQuery.page
    getList()
}
onMounted(() => {
    getList()
})
</script>
<style lang="scss" scoped></style>